import DataItemModel from "../../../cfw/mvc/DataItemModel";
import { SnowBodyModelEnum } from "../../../public/GameEnumConfig";
import User from "../../db/User";
import { ItemState } from "../../../cfw/tools/Define";
import Player from "../../player/Player";
/**
* 雪人装饰品
**/
export default class SnowBodyModel extends DataItemModel {

	static CLASS_NAME: string = 'SnowBodyModel'
	init(id, data) {
		super.init(id, data)
		this.setState(User.instance().getSnowBodyState(this.ID))
	}
	getOpenLevel() {
		let num = this.data[SnowBodyModelEnum.adge]
		return num ? num : 0
	}
	needBuy() {
		let cost: number[] = this.getCostItem()
		return cost && cost.length > 0 && this.getState() != ItemState.GOT
	}
	isOpen() {
		return Player.instance().getLevel() >= this.getOpenLevel()
	}
	setState(s: ItemState) {
		super.setState(s)
		//cc.log(' setState s ', s, ' ID ', this.ID)
		User.instance().setSnowBodyState(this.ID, s)
	}

	// icon
	getIcon() {
		return 'texture/snow_body/' + this.data[SnowBodyModelEnum.icon]
	}
	// 图标缩放
	getScale() {
		return this.data[SnowBodyModelEnum.scale]
	}
	// 消费道具
	getCostItem() {
		return this.data[SnowBodyModelEnum.costItem]
	}
	// 类型
	getType() {
		return this.data[SnowBodyModelEnum.type]
	}
	// 偏移量
	getOffset() {
		return this.data[SnowBodyModelEnum.offset]
	}
	// 背面图片
	getBack() {
		return 'texture/snow_body/' + this.data[SnowBodyModelEnum.back]
	}



}